package com.coursehub.exercise.service;

import com.coursehub.exercise.entity.Exercise;
import com.coursehub.exercise.entity.Submission;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

public interface ExerciseService {
    
    // 作业管理
    Exercise createExercise(Exercise exercise);
    Exercise updateExercise(Long id, Exercise exercise);
    void deleteExercise(Long id);
    Optional<Exercise> getExerciseById(Long id);
    List<Exercise> getAllExercises();
    List<Exercise> getExercisesByCourse(Long courseId);
    List<Exercise> getExercisesByClass(Long classId);
    List<Exercise> getExercisesByTeacher(Long teacherId);
    List<Exercise> getExercisesByType(Exercise.ExerciseType type);
    List<Exercise> searchExercisesByTitle(String title);
    List<Exercise> getExercisesDueBetween(LocalDateTime startDate, LocalDateTime endDate);
    List<Exercise> getOverdueExercises();
    
    // 作业提交管理
    Submission submitExercise(Submission submission);
    Submission updateSubmission(Long id, Submission submission);
    void deleteSubmission(Long id);
    Optional<Submission> getSubmissionById(Long id);
    List<Submission> getSubmissionsByExercise(Long exerciseId);
    List<Submission> getSubmissionsByStudent(Long studentId);
    Optional<Submission> getSubmissionByExerciseAndStudent(Long exerciseId, Long studentId);
    List<Submission> getSubmissionsByStatus(Submission.SubmissionStatus status);
    List<Submission> getSubmissionsNeedingGrading();
    
    // 评分管理
    Submission gradeSubmission(Long submissionId, Integer score, String feedback, Long gradedBy);
    List<Submission> getGradedSubmissionsByExercise(Long exerciseId);
    Double getAverageScoreByExercise(Long exerciseId);
    
    // 统计功能
    long countExercisesByTeacher(Long teacherId);
    long countExercisesByCourse(Long courseId);
    long countExercisesByClass(Long classId);
    long countSubmissionsByExercise(Long exerciseId);
    long countSubmissionsByStudent(Long studentId);
    long countGradedSubmissionsByExercise(Long exerciseId);
    boolean hasStudentSubmitted(Long exerciseId, Long studentId);
}